package com.ruoyi.web.controller.quate;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.Quote;
import com.ruoyi.system.service.IQuoteService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 项目报价清单Controller
 * 
 * @author xiongpeng
 * @date 2024-12-29
 */
@RestController
@RequestMapping("/quote/quote")
public class QuoteController extends BaseController
{
    @Autowired
    private IQuoteService quoteService;

    /**
     * 查询项目报价清单列表
     */
    @PreAuthorize("@ss.hasPermi('quote:quote:list')")
    @GetMapping("/list")
    public TableDataInfo list(Quote quote)
    {
        startPage();
        List<Quote> list = quoteService.selectQuoteList(quote);
        return getDataTable(list);
    }

    /**
     * 导出项目报价清单列表
     */
    @PreAuthorize("@ss.hasPermi('quote:quote:export')")
    @Log(title = "项目报价清单", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Quote quote)
    {
        List<Quote> list = quoteService.selectQuoteList(quote);
        ExcelUtil<Quote> util = new ExcelUtil<Quote>(Quote.class);
        util.exportExcel(response, list, "项目报价清单数据");
    }

    /**
     * 获取项目报价清单详细信息
     */
    @PreAuthorize("@ss.hasPermi('quote:quote:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(quoteService.selectQuoteById(id));
    }

    /**
     * 新增项目报价清单
     */
    @PreAuthorize("@ss.hasPermi('quote:quote:add')")
    @Log(title = "项目报价清单", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Quote quote)
    {
        return toAjax(quoteService.insertQuote(quote));
    }

    /**
     * 修改项目报价清单
     */
    @PreAuthorize("@ss.hasPermi('quote:quote:edit')")
    @Log(title = "项目报价清单", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Quote quote)
    {
        return toAjax(quoteService.updateQuote(quote));
    }

    /**
     * 删除项目报价清单
     */
    @PreAuthorize("@ss.hasPermi('quote:quote:remove')")
    @Log(title = "项目报价清单", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(quoteService.deleteQuoteByIds(ids));
    }
}
